﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PMSGSC.Common;
using DevExpress.XtraEditors;
using PMSGSC.DAL;
using PMSGSC.BLL;
using DevExpress.XtraEditors.Repository;
using DevExpress.XtraEditors.Controls;
using System.Globalization;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Columns;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Data.Linq;
using DevExpress.Utils.OAuth.Provider;
using DevExpress.XtraRichEdit.Model;
using System.Diagnostics;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
using DevExpress.XtraGrid.Localization;
using DevExpress.XtraTab;
using DevExpress.XtraBars;
namespace PMSGSC.App
{
    public partial class rpWorkOrders : DevExpress.XtraReports.UI.XtraReport
    {
        public rpWorkOrders(List<WorkOrder> dataSource, int type)
        {
            InitializeComponent();
            if (0 == type)
                dataSource = dataSource.OrderBy(n => n.WorkOrderNumber).ToList();
            else
            {
                if (1 == type)
                    dataSource = dataSource.OrderBy(n => n.Equipment.CodeEquipment).ToList();
                else
                    dataSource = dataSource.OrderBy(n => n.NextDue).ToList();
            }

            bindingSource1.DataSource = dataSource;
            xrLabel33.Text = DateTime.Now.Date.ToString("MM/dd/yyyy");
            OpenDocument();
        }
        private void OpenDocument()
        {
            string Address = Application.StartupPath + "\\Attachment\\";
            Directory.CreateDirectory(Address);
            if (null != bindingSource1.DataSource)
            {
                try
                {
                    WorkOrder workOrder = bindingSource1.Cast<WorkOrder>().ToList()[0];
                    string fileName = workOrder.Ship.NameShip + workOrder.Ship.Extension;
                    Address += fileName;
                    xrPictureBox1.ImageUrl = Address;
                }
                catch { }
            }
        }
    }
}
